package GUI;
/**
 * The parent type user can watch the details for all his children that 
 * are registered 
 */
import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.Vector;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JButton;

import Common.StudentClass;



public class ShowDataScreenParent extends JPanel {
   
	
	
	
    private JLabel lblViewAcademicData = null;
	private JButton btnBack = null;
	private Dimension defaultDim=null;
	private JScrollPane scrollPane=null;
	public String[][]data = null;
	//private ParentMainMenu pmn=null;
	private  JTable dataTable_1=null;
	private String IsExceptional = "Exceptional request approved";
 
    
	
	public ShowDataScreenParent(StudentClass StdCls, ParentMainMenu pmn) {
    	
        super(new GridLayout(1,0));
 
        String[] columnNamesStr = {"Year","Semester","Course", "Grade","Comments", "Evaluation form"};
        data = new String[StdCls.ListOfCourses.lOfCourses.size()][6];
    	
    	for(int i=0, j=0,count=0;i<StdCls.ListOfCourses.lOfCourses.size();i++)
    	{
    	if((pmn.user.getYear().equals((StdCls.ListOfCourses.lOfCourses.get(i).getYear().toString())))&&
    		(pmn.user.getSem().equals(StdCls.ListOfCourses.lOfCourses.get(i).getSemester().toString())&&
    		(pmn.user.getCourse().endsWith(StdCls.ListOfCourses.lOfCourses.get(i).getCid().toString()))))
    			
    	{
    		 data[count][j]=StdCls.ListOfCourses.lOfCourses.get(i).getYear().toString() ;
    		 data[count][j+1]=StdCls.ListOfCourses.lOfCourses.get(i).getSemester().toString();
    		 data[count][j+2]=StdCls.ListOfCourses.lOfCourses.get(i).getCname().toString()+" "+  StdCls.ListOfCourses.lOfCourses.get(i).getCid().toString();
    		 data[count][j+3]=StdCls.ListOfCourses.lOfCourses.get(i).getGrade().toString();
    		 if(!StdCls.ListOfCourses.lOfCourses.get(i).getIsExeptional()) IsExceptional=" ";
    		 data[count][j+4]=IsExceptional;//Isexceptional
    		 data[count][j+5]=null;// a cell for a link to the evaluation file
    		 count++;
    	}	
    	 System.out.println(StdCls.ListOfCourses.lOfCourses.size());
    	 System.out.println(StdCls.ListOfCourses.lOfCourses.get(i).getCid().toString());
    	
    	 System.out.println(StdCls.ListOfCourses.lOfCourses.get(i).getCname().toString());
    	 System.out.println(StdCls.ListOfCourses.lOfCourses.get(i).getGrade().toString());
    	 System.out.println(StdCls.ListOfCourses.lOfCourses.get(i).getYear().toString());
    	 System.out.println(StdCls.ListOfCourses.lOfCourses.get(i).getSemester().toString());
    	 System.out.println(StdCls.ListOfCourses.lOfCourses.get(i).getIsExeptional().toString());
    	}
 
         
        final JTable table = new JTable(data, columnNamesStr);
        table.setPreferredScrollableViewportSize(new Dimension(500, 500));
        table.setFillsViewportHeight(true);
        printDebugData(table);
      
        
      
 
        //Create the scroll pane and add the table to it.
        JScrollPane scrollPane = new JScrollPane(table);
 
        //Add the scroll pane to this panel.
        add(scrollPane);
        
    }
 
    private void printDebugData(JTable table) {
        int numRows = table.getRowCount();
        int numCols = table.getColumnCount();
        javax.swing.table.TableModel model = table.getModel();
 
        System.out.println("Value of data: ");
        for (int i=0; i < numRows; i++) {
            System.out.print("    row " + i + ":");
            for (int j=0; j < numCols; j++) {
                System.out.print("  " + model.getValueAt(i, j));
            }
            System.out.println();
        }
        System.out.println("--------------------------");
    }
    
  /*  public void setParentMainMenu(ParentMainMenu p)
    {
    	this.pmn=p;
    	
    }*/
 
   
}




